package raft.node;


import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;

@Getter
@Setter
public class PeerSet {

    public List<String> list = new ArrayList<>();

    private volatile String leader ;

    private volatile String self;


    private PeerSet() {
    }

    public static PeerSet getInstance() {
        return PeerSetLazyHolder.INSTANCE;
    }

    private static class PeerSetLazyHolder {

        private static final PeerSet INSTANCE = new PeerSet();
    }

    public List<String> getPeersWithOutSelf() {
        List<String> list2 = new ArrayList<>(list);
        list2.remove(self);
        return list2;
    }

    public  void addPeer(String add){
        list.add(add);
    }
}
